
<?php

	/*
	*
	* @header pname 
	*/

	require_once("connect_to_database.php");

	$project_name = mysql_real_escape_string($_POST['project']);
	

	//chat tables are named in the form name_chat
	$query = ("SELECT username,message,color,time from `".$project_name."_chat` order by time");
	$result = mysql_query($query);
	if(!$result)
		die(mysql_error());

	//Display messages orderd by time stamp
	while ($row = mysql_fetch_assoc($result)) {
		echo sprintf("<span class='chat_time'>".$row['time']."</span><br/>");
		echo sprintf("<span class='chat_message'><font weight='bold'; color='".$row['color']."'>".$row['username'].": </font> ".$row['message']."</span><br/>");
	}
	
	echo ('<script type="text/javascript">
	//autoRefresh
	var users_timeout = startChatRefresh();
	</script>');

?>
